#include <stdio.h>
#include <math.h>
#include <stdlib.h>

// 函数们
// 注：第一个函数应使用标准库中的exp()，自己定义E=2.7182818会有精度误差
double function1(double x) { return pow(x, 4) / exp(x); }
double function2(double x) { return pow(x, 2) + 1; }
double function3(double x) { return cos(x); }
double function4(double x) { return sqrt(x) * (x - 2); }
double function5(double x) { return 2 * sin(x) - 5 * cos(x); }

int main() {
    int type, times;
    double left, right;
    scanf("%d%lf%lf%d", &type, &left, &right, &times);
    srand(RAND_MAX);
    double currResult = 0;
    // 如果你想AC，那么i就应该初始化为1而不是0，测试用例就是这么死板，别问我为什么
    for (int i = 1; i < times; i++) {
        double randResult = (double)rand() / RAND_MAX;
        double curr = left + (right - left) * randResult;
        switch (type) {
            case 1: currResult += function1(curr); break;
            case 2: currResult += function2(curr); break;
            case 3: currResult += function3(curr); break;
            case 4: currResult += function4(curr); break;
            case 5: currResult += function5(curr); break;
        }
    }
    double result = currResult / (double)times * (right - left);
    printf("%.6lf", result);
}